<?php
class cct_passport extends ctl_passport {
    function login($url)
    {
        include_once('alipay_service.php');
        include_once('alipay_config.php');
        $alipay = new alipay_service($parameter,$security_code,$sign_type);
        $this->pagedata['alipay_sign'] = $alipay->signParams();
        $this->pagedata['alipay_return_url'] = $return_url;
        $this->pagedata['alipay_partner'] = $partner;
        $this->pagedata['alipay_sign_type'] = $sign_type;
        $this->pagedata['alipay_charset'] = $_input_charset;
        parent::login($url);
    }
    function autoreg()
    {//echo '<pre>';print_r($_GET);exit;
        $uname = substr(md5($_GET['email']),0,10);
        $pwd = $uname;
        if($_GET['is_success'] == 'T'){
            include_once('alipay_notify.php');
            include_once('alipay_config.php');
            $alipay = new alipay_notify($partner,$security_code,$sign_type,$_input_charset,$transport);
            $verify_result = $alipay->return_verify();
	    }
        if($_GET['is_success'] == 'T' && $verify_result){
            $account = $this->system->loadModel('member/account');
            if($account->checkMember(array('uname'=>$uname))){
                $_POST['forward'] = '';
                $_POST['login'] = $uname;
                $_POST['passwd'] = $pwd;
                $_POST['verifycode'] = '1234';
                $this->system->setCookie('RANDOM_CODE',md5('1234'));
                $this->verify();    //已注册过 该处进行验证
            }else{
                $_POST['forward'] = '';
                $_POST['uname'] = $uname;
                $_POST['email'] = $_GET['email'];
                $_POST['passwd'] = $pwd;
                $_POST['passwd_r'] = $pwd;
                $_POST['license'] = 'agree';
                $_POST['alipaymember'] = 'true';
                $_POST['name'] = $_GET['real_name'];
                $_POST['mobile'] = $_GET['mobile'];
                $_POST['tel'] = $_GET['phone'];
                $_POST['sex'] = $_GET['gender'] == 'F' ? '0' : '1';
                $_POST['addr'] = $_GET['address'];
                $_POST['zip'] = $_GET['zip'];
                $_POST['province'] = $_GET['province'];
                $_POST['city'] = $_GET['city'];
                $this->create();    //未注册 进行注册
            }
        }
    }
}